package com.openway.game;

import com.openway.game.view.View;
import com.openway.game.view.impl.ConsoleTextView;
import com.openway.game.view.impl.PseudoGraphConsoleView;
import com.openway.game.view.impl.PseudoGraphFileView;

import java.io.IOException;

/**
 * @author Created: 28.02.12 22:55
 * @version $Date$ $Revision$
 */
public class Main {

    public static void main(String[] args) {
        Game game = Game.getInstance();
        game.startNewGame();
        for (int i = 1; i < 200; i++) {
//            printStateInPseudoGraphToConsole();
            game.step();
        }
        printStateInPseudoGraphToFile("state200.txt");

        for (int i = 1; i < 100; i++) {
            game.step();
        }
        printStateInPseudoGraphToFile("state300.txt");

        for (int i = 1; i < 200; i++) {
            game.step();
        }
        printStateInPseudoGraphToFile("state500.txt");
    }
    
    private static void printStateInPseudoGraphToFile(String fileName) {
        View view = new PseudoGraphFileView(fileName);
        try {
            view.render();
        } catch (IOException e) {
            System.out.println("View rendering exception " + e.getMessage());
        }
    }

    private static void printStateInPseudoGraphToConsole() {
        View view = new PseudoGraphConsoleView();
        try {
            view.render();
        } catch (IOException e) {
            System.out.println("View rendering exception " + e.getMessage());
        }
    }

    private static void printTextStateToConsole() {
        View view = new ConsoleTextView();
        try {
            view.render();
        } catch (IOException e) {
            System.out.println("View rendering exception " + e.getMessage());
        }
    }
}
